import {Injectable} from '@angular/core';
import { _HttpClient} from '@delon/theme';
import { BaseService, httpOptions } from "../../../core/service/base.service";
import {environment} from '@env/environment';
import { Observable } from "rxjs";
import { catchError, tap } from "rxjs/operators";

@Injectable({
  providedIn: 'root'
})
export class TweetsService extends BaseService {

  private url = 'api/tweets';

  getUrl(): string {
    return this.url;
  }

  constructor(http: _HttpClient) {
    super(http);
  }

  up(id: any): Observable<any> {
    return this.http.post<any>(this.getUrl() + '/up/' + id, null, httpOptions).pipe(
      tap((obj: any) => this.log(`added object =${obj}`)),
      catchError(this.handleError<any>('addany')),
    );
  }

}
